<include file="Public/header" />
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>商户分类</h3>
      <ul class="tab-base">
        <li><a href="{:U('Store/storeclass')}"><span>管理</span></a></li>
		<li><a href="javascript:void(0);"  class="current"><span>添加</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="add_form" method="post" enctype="multipart/form-data">
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="class_name">分类名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" name="class_name" id="class_name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="class_pid">上级分类:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
              <select id="class_pid" name="class_pid" class="valid" >
              <option value="0">无上级分类</option>
              <volist name="p_class" id="val">
              <option value="{$val['class_id']}" <if condition="$class_pid eq $val['class_id']">selected="selected"</if>>{$val['class_name']}</option>
              </volist>
            </select></td>
          <td class="vatop tips"></td>
        </tr>
    
        <tr>
          <td colspan="2" class="required"><label for="class_img">分类图片:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
           <span class="type-file-box">
            <input name="class_img" type="file" class="type-file-file" id="class_img" size="30" hidefocus="true" yun_type="microshop_goods_class_image">
           </span>
          </td>
          <td class="vatop tips">建议上传图标尺寸为：62px*62px</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="class_sort" class="validation">排序:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input id="class_sort" name="class_sort" type="text" class="txt"/></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="class_recommend" >推荐:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff">
          	<label for="class_recommend1" class="cb-enable "><span>是</span></label>
            <label for="class_recommend2" class="cb-disable selected" ><span>否</span></label>
            <input id="class_recommend1" name="class_recommend"  value="1" type="radio">
            <input id="class_recommend2" name="class_recommend" checked value="0" type="radio">
          </td>
          <td class="vatop tips">
          	<span class="vatop rowform">首页推荐</span>
          </td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan="2"><a id="submit" href="javascript:void(0)" class="btn"><span>保存</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript">
$(document).ready(function(){
    //文件上传
    var textButton="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />";
    $(textButton).insertBefore("#class_img");
    $("#class_img").change(function(){
        $("#textfield1").val($("#class_img").val());
    });

    $("#submit").click(function(){
        $("#add_form").submit();
    });

    $("input[yun_type='microshop_goods_class_image']").live("change", function(){
		var src = getFullPath($(this)[0]);
		$(this).parent().prev().find('.low_source').attr('src',src);
		$(this).parent().find('input[class="type-file-text"]').val($(this).val());
	});


    $('#add_form').validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
            class_name: {
                required : true,
                maxlength : 10
            },
            class_sort: {
                required : true,
                digits: true
            }
        },
        messages : {
            class_name: {
                required : "请输入分类名称",
                maxlength : jQuery.validator.format("10个字符以内")
            },
            class_sort: {
                required : "请输入排序",
                digits: "输入格式错误"
            }
        }
    });
});
</script> 
<include file="Public/footer" />